-module(ssu2015DeviceTest_sup).

-behaviour(supervisor).

%% API
-export([start_link/0]).

%% Supervisor callbacks
-export([init/1]).

%% ===================================================================
%% API functions
%% ===================================================================

start_link() ->
  %server name, callback(has init()), args for init
  Args = [],
  supervisor:start_link({local, ?MODULE}, ?MODULE, Args).

%% ===================================================================
%% Supervisor callbacks
%% ===================================================================

init([]) ->
  AllowedRestarts = 5,
  MaxSeconds = 1,
  SupervisorSpec = {one_for_one, AllowedRestarts, MaxSeconds},% independent threads
  ChildSpecs = getChildSpecs(),
  {ok, {SupervisorSpec, ChildSpecs}}.

getChildSpecs() ->
  LastWillTime = 5000,
  RestartOnlyIfFailed = transient,
  [{ch1, {server_logic, start, []}, RestartOnlyIfFailed, LastWillTime, worker, [server_logic]}]
.

